package servlet.zhouchao;

import service.GoodsClassService;
import service.impl.GoodsClassServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(value = "/DeleteGoodsClassServlet")
public class DeleteGoodsClassServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String clId=request.getParameter("clId");
        GoodsClassService goodsClassService=new GoodsClassServiceImpl();
        int i=goodsClassService.delGoodsClass(Integer.parseInt(clId));
        if(i>0){
            request.getRequestDispatcher("GoodsClassPageBeanListServlet").forward(request,response);
        }
        else{
            response.getWriter().print("删除失败");
        }

    }
}
